<?php
/**
 * User: hjd-yao
 * Date: 2018/11/6
 * Time: 16:59
 */

namespace App\Models\System;


use App\Models\BaseModel;
use Illuminate\Support\Facades\Cache;

class ConfigModel extends BaseModel
{
    protected $table = 'sys_config';

    public $timestamps = false;


    public function clearConfigCache()
    {
        Cache::forget('website');
    }

    public function extraFormat($value)
    {
        $array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
        if(strpos($value,':')){
            $value  = array();
            foreach ($array as $val) {
                if(strpos($val,':')){
                    list($k, $v) = explode(':', $val);
                    $value[$k]   = $v;
                }
            }
        }else{
            $value =    $array;
        }
        return $value;
    }
}